#ifndef DMNBTEXT_H_
#define DMNBTEXT_H_

#include<iostream>
#include<vector>
#include<map>
#include<fstream>
#include<cstring>
#include<string>
#include "cppjieba/Jieba.hpp"
#include "dnbbinary.h"
using namespace std;

class DMNBText {
    
    public:
        // 类别下标为numAttributes.
        DMNBText();
        ~DMNBText();
        void initClassifier(string trainFile, bool multiNominal, int numIterations);
        void loadClassifier(string modelFile);
        void saveClassifier(string modelFile);
        void buildClassifier();
        void destoryClassifier();
        void updateClassifier(map<int,int> &);
        int getLogProbForTargetClass(map<int,int> &, double *);
        void makeInstance(string text, map<int, int> &);
        int getNumClass(){return m_numClass;};
        int getNumWord(){return m_numWord;};
        string predict(string text);

        void loadTrainFile(string trainFile);
        void loadModelFile(string modelFile);

	    vector<map<int,int>> m_instances;
        // 类别转换
        map<string,int> m_classIndexMap;

        int  m_numIterations;

        // 以下保存二进制文件供预测用.
        bool m_multinominal;
        int m_numClass;
        int m_numWord;

        // 词特征
        map<string,int> m_wordIndexMap;
        map<int,string> m_indexClassMap; 

        DNBBinary * m_binaryClassifiers;
};

#endif
